﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DACK_N28_QLRCP
{
    class Functions
    {
        public static byte[] encryptData(string data)
        {
            System.Security.Cryptography.MD5CryptoServiceProvider md5Hasher = new System.Security.Cryptography.MD5CryptoServiceProvider();
            byte[] hashedBytes;
            System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
            hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(data));
            return hashedBytes;
        }

        //Mã hóa password 
        public static string md5(string data)
        {
            return BitConverter.ToString(encryptData(data)).Replace("-", "").ToLower();
        }


        public static string ChuanDate(DateTime Dates)
        {
            return string.Format("{0:00}/{1:00}/{2:00}", Dates.Month, Dates.Day, Dates.Year.ToString().Substring(2, 2));
        }

        public static string Create_PassWord(DateTime Date)
        {
            string md5s = ChuanDate(Date);
            return md5(md5s);
        }
    }
}
